package com.example.demo.service.serviceImpl;

import com.example.demo.entity.FavoriteAuthor;
import com.example.demo.mapper.FavoriteAuthorMapper;
import com.example.demo.service.FavoriteAuthorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 收藏作者表(FavoriteAuthor)Service层
 *
 * @author 杨丽辉
 * @since 2021-03-06 14:40:00
 */
@Service
 @Transactional(rollbackFor = {RuntimeException.class, Exception.class})
public class FavoriteAuthorServiceImpl implements FavoriteAuthorService {
        @Autowired
        private FavoriteAuthorMapper favoriteAuthorMapper;


 /**
     * 通过ID和其他条件查询单条数据
     *
     * @param favoriteAuthor 实例对象
     * @return 实例对象
     */
       @Override
 @Transactional(rollbackFor = {RuntimeException.class, Exception.class})
     public FavoriteAuthor queryFavoriteAuthorLimit1(FavoriteAuthor favoriteAuthor){
     return  favoriteAuthorMapper.queryFavoriteAuthorLimit1( favoriteAuthor);
     }
     
 /**
     * 查询指定行数据
     * @param favoriteAuthor 实例对象
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
       @Override
 @Transactional(rollbackFor = {RuntimeException.class, Exception.class})
  public   List<FavoriteAuthor> queryAllFavoriteAuthorByLimit( FavoriteAuthor favoriteAuthor, Integer offset,  Integer limit){
   return favoriteAuthorMapper.queryAllFavoriteAuthorByLimit(favoriteAuthor, offset,limit);
  }

  /**
     * 查询数据条数
     * @return 条数
     */
       @Override
 @Transactional(rollbackFor = {RuntimeException.class, Exception.class})
   public int countAllFavoriteAuthor(FavoriteAuthor favoriteAuthor){
   return favoriteAuthorMapper.countAllFavoriteAuthor( favoriteAuthor);
   }
   /**
     * 通过实体作为筛选条件查询
     *
     * @param favoriteAuthor 实例对象
     * @return 对象列表
     */
       @Override
 @Transactional(rollbackFor = {RuntimeException.class, Exception.class})
   public List<FavoriteAuthor> queryAllFavoriteAuthor(FavoriteAuthor favoriteAuthor){
   return favoriteAuthorMapper.queryAllFavoriteAuthor(favoriteAuthor);
   }
  /**
     * 新增数据
     *
     * @param favoriteAuthor 实例对象
     * @return 影响行数
     */
     @Override
   @Transactional(rollbackFor = {RuntimeException.class, Exception.class})
    public int insertFavoriteAuthor(FavoriteAuthor favoriteAuthor){
    return  favoriteAuthorMapper.insertFavoriteAuthor( favoriteAuthor);
    }
  /**
     * 修改数据
     *
     * @param favoriteAuthor 实例对象
     * @return 影响行数
     */
       @Override
 @Transactional(rollbackFor = {RuntimeException.class, Exception.class})
     public  int updateFavoriteAuthor(FavoriteAuthor favoriteAuthor){
         return favoriteAuthorMapper.updateFavoriteAuthor( favoriteAuthor);
     }

    /**
     * 通过主键删除数据
     * @param favoriteAuthorId 主键
     * @return 影响行数
     */
      @Override
  @Transactional(rollbackFor = {RuntimeException.class, Exception.class})
   public  int deleteFavoriteAuthorById(String favoriteAuthorId){
   return  favoriteAuthorMapper.deleteFavoriteAuthorById( favoriteAuthorId);
   }
     /**
     * 通过主键列表删除，列表长度不能为0
     * @param list 集合
     * @return 条数
     */
      @Override
  @Transactional(rollbackFor = {RuntimeException.class, Exception.class})
  public  int deleteFavoriteAuthorByIds( List<String> list){
    return  favoriteAuthorMapper.deleteFavoriteAuthorByIds(  list);
  }
    
       /**
     * 通过主键修改实体列表，列表长度不能为0，注意：当实体属性为null时，对应的列也会别更新为null
     * @param list 集合
     * @return 条数
     */
       @Override
 @Transactional(rollbackFor = {RuntimeException.class, Exception.class})
   public int updateFavoriteAuthorBatch( List<FavoriteAuthor> list){
   return  favoriteAuthorMapper.updateFavoriteAuthorBatch(list);
   }
    /**
     * 批量其他列,除主键以外的列，列表长度不能为0,字段是空的就置为null
     * @param list 集合
     * @return 条数
     */
      @Override
  @Transactional(rollbackFor = {RuntimeException.class, Exception.class})
 public   int insertFavoriteAuthorBatch( List<FavoriteAuthor> list){
 return favoriteAuthorMapper.insertFavoriteAuthorBatch( list);
 }
      /**
     * 通过实体非空属性删除
     * @param favoriteAuthor  实体
     * @return 条数
     */
        @Override
@Transactional(rollbackFor = {RuntimeException.class, Exception.class})
  public   int deleteFavoriteAuthorByEntity( FavoriteAuthor favoriteAuthor){
  return  favoriteAuthorMapper.deleteFavoriteAuthorByEntity(  favoriteAuthor);
  }
    /**
     * 通过实体不为空的属性作为筛选条件查询列表
     * @param favoriteAuthor  实体
     * @return list
     */
       @Override
 @Transactional(rollbackFor = {RuntimeException.class, Exception.class})
   public  List<FavoriteAuthor> listFavoriteAuthorByEntity(FavoriteAuthor favoriteAuthor){
   return favoriteAuthorMapper.listFavoriteAuthorByEntity( favoriteAuthor);
   }

 /**
     * 新增实体属性不为null的列
     * @param favoriteAuthor  实体
     * @return 条数
     */
       @Override
 @Transactional(rollbackFor = {RuntimeException.class, Exception.class})
   public  int insertFavoriteAuthorSelect( FavoriteAuthor favoriteAuthor){
      return favoriteAuthorMapper.insertFavoriteAuthorSelect( favoriteAuthor);

   }
   
      /**
     * 批量新增新增实体属性不为null的列
     * @param list  实体
     * @return 条数
     */
        @Override
@Transactional(rollbackFor = {RuntimeException.class, Exception.class})
  public  int insertFavoriteAuthorListSelect( List<FavoriteAuthor> list){

     return favoriteAuthorMapper.insertFavoriteAuthorListSelect( list);
      }
     /**
     * 通过实体不为空的属性作为筛选条件查询单个
     * @param favoriteAuthor  实体
     * @return 单个
     */
     @Override
   @Transactional(rollbackFor = {RuntimeException.class, Exception.class})
    public  FavoriteAuthor getFavoriteAuthorByEntity(FavoriteAuthor favoriteAuthor){
     return  favoriteAuthorMapper.getFavoriteAuthorByEntity(favoriteAuthor);
    }

}

